package com.xavier.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Comments: 菜单类型
 */
@Getter
@AllArgsConstructor
public enum MenuTypeEnum {
	DIRECTORY              ((byte) 1, "目录"),
	MENU                   ((byte) 2, "菜单"),
	INTERFACE              ((byte) 3, "接口"),
	;

	private byte value;
	private String desc;

	public static boolean exists(Byte status) {
        if (status == null) {
            return false;
        }
        byte s = status.byteValue();
        return exists(s);
    }

    public static boolean exists(byte s) {
        for (MenuTypeEnum element : MenuTypeEnum.values()) {
            if (element.value == s) {
                return true;
            }
        }
        return false;
    }

    public boolean equal(Byte val) {
        return val == null ? false : val.byteValue() == this.value;
    }

	public static String getDescByValue(Byte value) {
		if (value == null) {
			return "";
		}
		for (MenuTypeEnum element : MenuTypeEnum.values()) {
			if (element.value == value.byteValue()) {
				return element.desc;
			}
		}
		return "";
	}
}
